package com.hcy.common.config;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.hcy.common.Impl.CommonInfoBzImpl;
import com.hcy.common.dto.response.CallCarConfigDTO;
import com.hcy.common.entity.CallCarConfig;
import com.hcy.rabbitbasicutils.utils.RedisUtils;
import org.apache.commons.lang.builder.ToStringBuilder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.stereotype.Component;

import java.util.Collections;
import java.util.Comparator;
import java.util.List;

/**
 * @Author huchenying
 * @Description
 * @Date 2022/3/20 16:13
 */
@Component
public class InitForRedisConfig implements ApplicationRunner {

    private static final Logger logger = LoggerFactory.getLogger(InitForRedisConfig.class);

    @Autowired
    CommonInfoBzImpl commonInfoBz;

    @Autowired
    RedisUtils redisUtils;

    @Override
    public void run(ApplicationArguments args) throws Exception {
        logger.info("InitForRedisConfig run start..");
        // 获取叫车config,放入redis中
        List<CallCarConfigDTO> list = commonInfoBz.getCallCarConfig();
        redisUtils.set("CALL_CAR_CONFIG", JSON.toJSONString(list));

        logger.info("InitForRedisConfig run end");
    }
}
